package org.lex.ftp.ui.queue;

import java.awt.Component;
import javax.swing.Icon;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import org.lex.ftp.queue.Task;
import org.lex.swing.IconSet;


public class SourceRenderer extends DefaultTableCellRenderer {
	private static final SourceRenderer instance = new SourceRenderer();

	public static SourceRenderer getInstance() {
		return instance;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		if (null == value)
			return this;
		Task task = (Task) value;
		Icon icon = new IconSet(8, task.getIcon(), task.getSourceIcon());
		this.setIcon(icon);
		return super.getTableCellRendererComponent(table, task.getSource(), isSelected, hasFocus, row, column);
	}
}
